package com.steak.concurrent.CompletableFuture.api.call;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

/**
 * @author 刘牌
 * @Title:
 * @date 2022-04-2311:43
 */
public class then {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //有返回值的异步回调函数
        CompletableFuture<Integer> applyResult = CompletableFuture.supplyAsync(() -> 100).thenApplyAsync(s -> s);
        System.out.println(applyResult.get());
        //无返回值的异步回调半数
        CompletableFuture<Void> runResult = CompletableFuture.supplyAsync(() -> 100).thenRunAsync(() -> {
            System.out.println("我是无返回值的异步回调函数");
        });
        System.out.println(runResult.get());
    }
}
